home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 8.6 KB | 326 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Frame.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef VIEW_H
- #include "View.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWGROWBX_H
- #include "FWGrowBx.h"
- #endif
-
- #ifndef FWSCLBAR_H
- #include "FWSclBar.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWTXTSHP_H
- #include "FWTxtShp.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWOVLSHP_H
- #include "FWOvlShp.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWTXTBOX_H
- #include "FWTxtBox.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #ifndef FWRESACC_H
- #include "FWResAcc.h"
- #endif
-
- #ifndef FWRESTYP_H
- #include "FWResTyp.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifndef FWSCRCON_H
- #include "FWScrCon.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- //========================================================================================
- // RunTime information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfclock
- #endif
-
- //========================================================================================
- // class CClockFrame
- //========================================================================================
-
- FW_DEFINE_AUTO(CClockFrame)
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::CClockFrame
- //----------------------------------------------------------------------------------------
-
- CClockFrame::CClockFrame(Environment* ev, ODFrame* odFrame,
- FW_CPresentation* presentation,
- CClockPart* clockPart,
- CClockContent* clockContent) :
- FW_CFrame(ev, odFrame, presentation, clockPart),
- fClockPart(clockPart),
- fBackgroundColor(FW_kRGBWhite),
- fClockContent(clockContent)
-
- {
- SetAdoptsContainerProperties(ev, TRUE);
-
- FW_DO_NOT_DEAD_STRIP(CAnalogView);
- FW_DO_NOT_DEAD_STRIP(CDigitalView);
- FW_DO_NOT_DEAD_STRIP(FW_CGrowBox);
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::~CClockFrame
- //----------------------------------------------------------------------------------------
-
- CClockFrame::~CClockFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::FacetAdded
- //----------------------------------------------------------------------------------------
-
- void CClockFrame::FacetAdded(Environment* ev, ODFacet* facet, unsigned short facetCount)
- {
- FW_CFrame::FacetAdded(ev, facet, facetCount);
-
- if (facetCount == 1)
- this->UpdateUsedAndActiveShapes(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CClockFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- // [HLX] This will be moved into an erase adorner
- if (IsRoot(ev))
- {
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
-
- FW_CRect invalidRect;
- vc.GetClipRect(invalidRect);
-
- #ifdef FW_BUILD_MAC
- FW_CInk ink(FW_kRGBWhite,
- FW_kRGBWhite,
- FW_kErase);
- #else
- FW_CInk ink(FW_CColor(::GetSysColor(COLOR_WINDOWTEXT), 0),
- FW_CColor(::GetSysColor(COLOR_APPWORKSPACE), 0),
- FW_kErase);
- #endif
- FW_CRectShape::RenderRect(vc, invalidRect, FW_kFill, ink);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::PresentationChanged
- //----------------------------------------------------------------------------------------
-
- void CClockFrame::PresentationChanged(Environment* ev)
- {
- FW_CFrame::PresentationChanged(ev);
-
- UpdateUsedAndActiveShapes(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::SetBackgroundColor
- //----------------------------------------------------------------------------------------
-
- void CClockFrame::SetBackgroundColor(Environment* ev, FW_CColor& newColor)
- {
- if (newColor != fBackgroundColor)
- {
- fBackgroundColor = newColor;
- Invalidate(ev);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::GetBackgroundColor
- //----------------------------------------------------------------------------------------
-
- void CClockFrame::GetBackgroundColor(FW_CColor* newColor) const
- {
- *newColor = fBackgroundColor;
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::AdjustUsedShape
- //----------------------------------------------------------------------------------------
- // 'suggestedUsedShape' is equal to the frame shape
-
- ODShape* CClockFrame::AdjustUsedShape(Environment* ev, ODShape* suggestedUsedShape)
- {
- FW_ASSERT(GetViewType(ev) == FW_CPart::fgViewAsFrameToken);
-
- FW_CRect usedRect = FW_GetShapeBoundingBox(ev, suggestedUsedShape);
-
- CClockView* clockView = GetClockView(ev);
- if (clockView == NULL)
- return FW_CFrame::AdjustUsedShape(ev, suggestedUsedShape);
- else
- return clockView->CreateUsedShape(ev, usedRect);
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::AdjustActiveShape
- //----------------------------------------------------------------------------------------
- // [HLX] Because OpenDoc uses the Frame shape as the default active shape I need to
- // adjust my active shape too.
-
- ODShape* CClockFrame::AdjustActiveShape(Environment* ev, ODFacet* facet, ODShape* suggestedActiveShape)
- {
- FW_UNUSED(facet);
- FW_ASSERT(GetViewType(ev) == FW_CPart::fgViewAsFrameToken);
-
- suggestedActiveShape->Acquire(ev);
- return suggestedActiveShape;
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::AdoptContainingPartProperties
- //----------------------------------------------------------------------------------------
-
- void CClockFrame::AdoptContainingPartProperties(Environment* ev,
- ODStorageUnit* propertyUnit)
- {
- FW_CColor newColor = FW_kRGBWhite;
-
- if (fClockPart->UseContainerColor() && propertyUnit && propertyUnit->Exists(ev, kBackgroundColorProp, kBackgroundColorValue, 0))
- {
- FW_PStorageUnitSink suSink(ev, propertyUnit, kBackgroundColorProp, kBackgroundColorValue);
- FW_PBufferedSink sink(ev, suSink);
- FW_CReadableStream stream(sink);
-
- stream >> newColor;
- }
-
- SetBackgroundColor(ev, newColor);
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::GetClockView
- //----------------------------------------------------------------------------------------
-
- CClockView* CClockFrame::GetClockView(Environment* ev) const
- {
- return (CClockView*)FindViewByID(ev, kClockViewID);
- }
-
- //----------------------------------------------------------------------------------------
- // CClockFrame::DoAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Handled CClockFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- FW_UNUSED(isRoot);
- if (hasMenuFocus)
- menuBar->EnableAndToggleCommand(ev, cClockType, TRUE, !fClockPart->IsAnalog(GetPresentation(ev)));
-
- return FW_kNotHandled;
- }
-
- //------------------------------------------------------------------------------
- // CClockFrame::DoMenu
- //------------------------------------------------------------------------------
-
- FW_Handled CClockFrame::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Handled menuHandled = FW_kHandled;
-
- switch (theMenuEvent.GetCommandID(ev))
- {
- case cClockType:
- {
- FW_CPresentation* previousPresentation = GetPresentation(ev);
- FW_CPresentation* currentPresentation = fClockPart->SwitchPresentation(previousPresentation);
- ChangePresentation(ev, currentPresentation);
-
- currentPresentation->ContentUpdated(ev);
-
- GetPart(ev)->Changed(ev); // document has changed (enable Save menu item)
- }
- break;
-
- default:
- menuHandled = FW_kNotHandled;
- }
-
- return menuHandled;
- }
-
-